Imports System
Imports System.Collections
Imports System.ComponentModel

Public Class WevConverter : Inherits TypeConverter

    Public Overrides Function GetCreateInstanceSupported(ByVal context As ITypeDescriptorContext) As Boolean
        Return True
    End Function

    Public Overrides Function GetPropertiesSupported(ByVal context As ITypeDescriptorContext) As Boolean
        Return True
    End Function
    
End Class

Public Class WevTestConverter : Inherits WevConverter

    Public Overrides Function CreateInstance(ByVal context As ITypeDescriptorContext, ByVal propertyValues As IDictionary) As Object
        If propertyValues Is Nothing Then
            Throw New ArgumentNullException("propertyValues")
        End If

        Dim _State As Object = propertyValues("State")
        
        Dim ret = New WevTest_T With {
            .State = _State
            }
        Return ret
    End Function

    Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal attributes As Attribute()) As PropertyDescriptorCollection
        Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(WevTest_T), attributes)
        Return props
    End Function

End Class

Public Class WevCurrentConverter : Inherits WevConverter

    Public Overrides Function CreateInstance(ByVal context As ITypeDescriptorContext, ByVal propertyValues As IDictionary) As Object
        If propertyValues Is Nothing Then
            Throw New ArgumentNullException("propertyValues")
        End If

        Dim _Ib As Object = propertyValues("Ib")
        Dim _Ic As Object = propertyValues("Ic")
        Dim _Id As Object = propertyValues("Id")
        Dim _Iq As Object = propertyValues("Iq")
        Dim _ActualTorque As Object = propertyValues("ActualTorque")
        
        Dim ret = New WevCurrent_T With {
            .Ib = _Ib,
            .Ic = _Ic,
            .Id = _Id,
            .Iq = _Iq,
            .ActualTorque = _ActualTorque
            }
        Return ret
    End Function

    Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal attributes As Attribute()) As PropertyDescriptorCollection
        Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(WevCurrent_T), attributes)
        Return props
    End Function

End Class

Public Class WevEncoderConverter : Inherits WevConverter

    Public Overrides Function CreateInstance(ByVal context As ITypeDescriptorContext, ByVal propertyValues As IDictionary) As Object
        If propertyValues Is Nothing Then
            Throw New ArgumentNullException("propertyValues")
        End If

        Dim _Radians As Object = propertyValues("Radians")
        Dim _RadianOffset As Object = propertyValues("RadianOffset")
        Dim _ActualPos As Object = propertyValues("ActualPos")
        Dim _Counts As Object = propertyValues("Counts")
        Dim _ActualRpm As Object = propertyValues("ActualRpm")
        Dim _RpmFiltered As Object = propertyValues("RpmFiltered")
        Dim _Warning As Object = propertyValues("Warning")
        Dim _Errorno As Object = propertyValues("Errorno")
        
        Dim ret = New WevEncoder_T With {
            .Radians = _Radians,
            .RadianOffset = _RadianOffset,
            .ActualPos = _ActualPos,
            .Counts = _Counts,
            .ActualRpm = _ActualRpm,
            .RpmFiltered = _RpmFiltered,
            .Warning = _Warning,
            .Errorno = _Errorno
            }
        Return ret
    End Function

    Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal attributes As Attribute()) As PropertyDescriptorCollection
        Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(WevEncoder_T), attributes)
        Return props
    End Function

End Class

Public Class WevPidConverter : Inherits WevConverter

    Public Overrides Function CreateInstance(ByVal context As ITypeDescriptorContext, ByVal propertyValues As IDictionary) As Object
        If propertyValues Is Nothing Then
            Throw New ArgumentNullException("propertyValues")
        End If

        Dim _VelKp As Object = propertyValues("VelKp")
        Dim _VelKi As Object = propertyValues("VelKi")
        Dim _PosKp As Object = propertyValues("PosKp")
        Dim _PosKi As Object = propertyValues("PosKi")
        
        Dim ret = New WevPid_T With {
            .VelKp = _VelKp,
            .VelKi = _VelKi,
            .PosKp = _PosKp,
            .PosKi = _PosKi
            }
        Return ret
    End Function

    Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal attributes As Attribute()) As PropertyDescriptorCollection
        Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(WevPid_T), attributes)
        Return props
    End Function

End Class

Public Class WevHeartBeatMasterConverter : Inherits WevConverter

    Public Overrides Function CreateInstance(ByVal context As ITypeDescriptorContext, ByVal propertyValues As IDictionary) As Object
        If propertyValues Is Nothing Then
            Throw New ArgumentNullException("propertyValues")
        End If

        Dim _Count As Object = propertyValues("Count")
        Dim _Enable As Object = propertyValues("Enable")
        Dim _EnableSetting As Object = propertyValues("EnableSetting")
        Dim _Reset As Object = propertyValues("Reset")
        Dim _Mode As Object = propertyValues("Mode")
        Dim _AutoPid As Object = propertyValues("AutoPid")
        Dim _SetPids As Object = propertyValues("SetPids")
        Dim _FeedForwardRatio As Object = propertyValues("FeedForwardRatio")
        Dim _VelSetpoint As Object = propertyValues("VelSetpoint")
        Dim _PosSetpoint As Object = propertyValues("PosSetpoint")
        Dim _Pids As Object = propertyValues("Pids")
        
        Dim ret = New WevHeartBeatMaster_T With {
            .Count = _Count,
            .Enable = _Enable,
            .EnableSetting = _EnableSetting,
            .Reset = _Reset,
            .Mode = _Mode,
            .AutoPid = _AutoPid,
            .SetPids = _SetPids,
            .FeedForwardRatio = _FeedForwardRatio,
            .VelSetpoint = _VelSetpoint,
            .PosSetpoint = _PosSetpoint,
            .Pids = _Pids
            }
        Return ret
    End Function

    Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal attributes As Attribute()) As PropertyDescriptorCollection
        Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(WevHeartBeatMaster_T), attributes)
        Return props
    End Function

End Class

Public Class WevAxisConverter : Inherits WevConverter

    Public Overrides Function CreateInstance(ByVal context As ITypeDescriptorContext, ByVal propertyValues As IDictionary) As Object
        If propertyValues Is Nothing Then
            Throw New ArgumentNullException("propertyValues")
        End If

        Dim _VbusVoltage As Object = propertyValues("VbusVoltage")
        Dim _EndstopState As Object = propertyValues("EndstopState")
        Dim _Offset As Object = propertyValues("Offset")
        Dim _IsActiveHigh As Object = propertyValues("IsActiveHigh")
        Dim _Pullup As Object = propertyValues("Pullup")
        Dim _Test As Object = propertyValues("Test")
        
        Dim ret = New WevAxis_T With {
            .VbusVoltage = _VbusVoltage,
            .EndstopState = _EndstopState,
            .Offset = _Offset,
            .IsActiveHigh = _IsActiveHigh,
            .Pullup = _Pullup,
            .Test = _Test
            }
        Return ret
    End Function

    Public Overrides Function GetProperties(ByVal context As ITypeDescriptorContext, ByVal value As Object, ByVal attributes As Attribute()) As PropertyDescriptorCollection
        Dim props As PropertyDescriptorCollection = TypeDescriptor.GetProperties(GetType(WevAxis_T), attributes)
        Return props
    End Function

End Class

